package com.yourcompany.api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yourcompany.api.entity.UserRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserRoleMapper extends BaseMapper<UserRole> {

    /**
     * 获取用户的角色ID列表
     */
    @Select("SELECT role_id FROM user_role WHERE user_id = #{userId} AND is_deleted = 0")
    List<Long> getRoleIdsByUserId(@Param("userId") Long userId);

    /**
     * 获取角色的用户ID列表
     */
    @Select("SELECT user_id FROM user_role WHERE role_id = #{roleId} AND is_deleted = 0")
    List<Long> getUserIdsByRoleId(@Param("roleId") Long roleId);
} 